package com.wudi.estate.service.impl.tolladministration;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wudi.estate.bean.ownermanagement.Personnel;
import com.wudi.estate.bean.tolladministration.PayItems;
import com.wudi.estate.mapper.tolladministration.PayItemsMapper;
import com.wudi.estate.service.ownermanagement.PersonnelService;
import com.wudi.estate.service.tolladministration.PayItemsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PayItemsServiceImpl implements PayItemsService {
    @Autowired
    private PayItemsMapper payItemsMapper;
    @Override
    public List<PayItems> selectAll() throws Exception {
        return payItemsMapper.selectList(null);
    }

    @Override
    public PayItems selectById(PayItems p) throws Exception {
        return payItemsMapper.selectById(p.getId());
    }

    @Override
    public void updateById(PayItems p) throws Exception {
        payItemsMapper.updateById(p);
    }

    @Override
    public void updateStateById(PayItems p) throws Exception {
        PayItems payItems = payItemsMapper.selectById(p.getId());
        if(payItems.isState()==true){
            payItems.setState(false);
        }
        payItemsMapper.updateById(p);
    }

    @Override
    public void insert(PayItems p) throws Exception {
        payItemsMapper.insert(p);
    }

    @Override
    public List<PayItems> selectByName(String chid) throws Exception {
        QueryWrapper<PayItems> queryWrapper = new QueryWrapper<>();
        queryWrapper.like("chid",chid);
        return payItemsMapper.selectList(queryWrapper);
    }
}
